package com.schoolgard.entitybean;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "USERS")
@SequenceGenerator (name="AUTO_ID", sequenceName="AUTO_ID")
public class Users implements java.io.Serializable {

	private static final long serialVersionUID = 201202251304L;

	private Long id;
	private Organization organization;
	private String name;
	private String loginid;
	private String password;
	private Short priority;
	private String mobile;
	private String mail;
	private Boolean status;
	private String guid;
	private Set<RoleOfUsers> RoleOfUserses = new HashSet<RoleOfUsers>(0);

	// Constructors

	/** default constructor */
	public Users() {
	}

	/** minimal constructor */
	public Users(Long id, Organization organization) {
		this.id = id;
		this.organization = organization;
	}

	/** full constructor */
	public Users(Long id, Organization organization, String name,
			String loginid, String password, Short priority, String mobile,
			String mail, Boolean status, String guid,
			Set<RoleOfUsers> RoleOfUserses) {
		this.id = id;
		this.organization = organization;
		this.name = name;
		this.loginid = loginid;
		this.password = password;
		this.priority = priority;
		this.mobile = mobile;
		this.mail = mail;
		this.status = status;
		this.guid = guid;
		this.RoleOfUserses = RoleOfUserses;
	}

	// Property accessors
	@Id
	@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
	@GeneratedValue (strategy=GenerationType.SEQUENCE, generator="AUTO_ID")
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ORGANIZATION_ID")
	public Organization getOrganization() {
		return this.organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	@Column(name = "NAME", length = 64)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "LOGINID", length = 100)
	public String getLoginid() {
		return this.loginid;
	}

	public void setLoginid(String loginid) {
		this.loginid = loginid;
	}

	@Column(name = "PASSWORD", length = 100)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "PRIORITY", precision = 3, scale = 0)
	public Short getPriority() {
		return this.priority;
	}

	public void setPriority(Short priority) {
		this.priority = priority;
	}

	@Column(name = "MOBILE", length = 64)
	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "MAIL", length = 100)
	public String getMail() {
		return this.mail;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	@Column(name = "STATUS", length = 1)
	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	@Column(name = "GUID", length = 64)
	public String getGuid() {
		return this.guid;
	}

	public void setGuid(String guid) {
		this.guid = guid;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "users")
	public Set<RoleOfUsers> getRoleOfUserses() {
		return this.RoleOfUserses;
	}

	public void setRoleOfUserses(Set<RoleOfUsers> RoleOfUserses) {
		this.RoleOfUserses = RoleOfUserses;
	}

}